﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Groep8
{
    public partial class Festival : Page
    {
        private DataTable dtFestivals;
        private int id = 0;

        // Uitvoeren stored procedures via de DataAccessLayer om informatie over het gevraagde festival op te vragen.
        protected void Page_Load(object sender, EventArgs e)
        {
            lblFestivalError.Visible = false;

            if (Request.QueryString["fest_id"] != null)
            {
                try
                {
                    id = Convert.ToInt32(Request.QueryString["fest_id"]);
                }
                catch (OverflowException)
                {
                    Console.WriteLine("{0} is outside the range of the Int32 type.", id);
                }
                catch (FormatException)
                {
                    Console.WriteLine("The {0} value '{1}' is not in a recognizable format.", id.GetType().Name, id);
                }
                DataAccessLayer d = new DataAccessLayer();
                dtFestivals = d.SelectWithParam("procedure_select_festival", id);
                if (dtFestivals.Rows.Count > 0)
                {

                    FestivalDetail.DataSource = dtFestivals;
                    FestivalDetail.DataBind();

                    dtFestivals = d.SelectWithParam("procedure_select_festival_bands_per_id", id);
                    FestivalDetailBands.DataSource = dtFestivals;
                    FestivalDetailBands.DataBind();

                    dtFestivals = d.SelectWithParam("procedure_select_festival_tickets_per_id", id);
                    FestivalDetailTickets.DataSource = dtFestivals;
                    FestivalDetailTickets.DataBind();

                    dtFestivals = d.SelectWithParam("procedure_select_festival_campings_per_id", id);
                    FestivalDetailCampings.DataSource = dtFestivals;
                    FestivalDetailCampings.DataBind();
                }
                else
                {
                    lblFestivalError.Text = "Ooops , no festival found with this id !";
                    lblFestivalError.Visible = true;
                }
            }
            else
            {
                lblFestivalError.Text = "Ooops , please supply a Festival-ID !";
                lblFestivalError.Visible = true;
            }


        }

    }
}